<template>
  <view class="container_page">
    <!-- 顶部自定义导航栏 -->
    <action-bar :options="navOptions" />
    <view class="main">
      <uni-section title="机构基本信息" type="line">
        <view class="formItem">
          <view class="label">机构名称</view>
          <view class="content">{{ form.name }}</view>
        </view>

        <view class="formItem">
          <view class="label">统一信用代码</view>
          <input class="content" v-model="form.code" disabled />
        </view>

        <view class="formItem">
          <view class="label">机构地址</view>
          <view class="content">{{ form.address }}</view>
        </view>
        <view class="formItem">
          <view class="label">服务类别</view>
          <uni-data-checkbox :multiple="true" :disabled="true" v-model="form.serviceType" :value="form.serviceType"
            :localdata="serviceTypeList"></uni-data-checkbox>
        </view>

        <view class="formItem">
          <view class="label">法定代表人</view>
          <input class="content" v-model="form.personName" disabled />
        </view>
        <view class="formItem">
          <view class="label">机构联系电话</view>
          <input class="content" v-model="form.companyPhone" disabled/>
        </view>
      </uni-section>
      <toast></toast>
    </view>

    <view class="allBtn">
      <view class="btn" @click="submit">
        返回
      </view>
    </view>
  </view>
</template>
<script>
import UniDataCheckbox from '@/components/uni-data-checkbox/uni-data-checkbox.vue';
import { serviceTypeList } from '@/utils/dictList.js';
export default {
  components: { UniDataCheckbox },
  data() {
    return {
      // 服务类型
      serviceTypeList,
      navOptions: { // 导航栏配置参数
        statusBar: 'dark',
        left: {
          icon: 'back'
        },
        center: {
          title: '机构信息'
        }
      },
      agencyId: '',
      form: {
        name: '',
        code: '',
        area: '',
        address: '',
        serviceType: '',
        companyName: '',
        companyPhone: '',
        businessLicense: '',
        personName: '',
        phone: '',
        idcardType: '',
        idcard: '',
        image: '',
        positivePhoto: '',
        backPhoto: '',
        loading: false,
      }

    }
  },
  onLoad(options) {
    this.agencyId = options.id
  },
  onShow: function () {
    this.getForm()
  },
  methods: {
    // 获取表单信息
    getForm() {
      if (this.loading) return

      this.loading = true
      uni.showLoading({
        title: '正在加载请稍后',
        mask: true
      });
      this.$store.dispatch('organizeInfo_form', this.agencyId).then(res => {
        if (res && res.code === 200) {
          this.form = res.data
          this.form.serviceType = res.data.serviceType.split(",")
        }
      }).finally(() => {
        this.loading = false
        uni.hideLoading();
      })
    },
  }
}
</script>
<style lang="scss" scoped>
@import "@/styles/variables.scss";

::v-deep .uni-section {
  margin-top: 0;
  background-color: transparent;
}

::v-deep .uni-data-checklist .checklist-group {
  justify-content: flex-end;

  .checklist-box {
    margin-right: 0;
  }
}

.container_page {
  width: 100%;
  min-height: 100vh;
}

.main {
  height: calc(100vh - 80rpx);
  background: $OVERALL_SITUATION_BACKGROUND_GRADIENT;

  .formItem {
    width: calc(100% - 40rpx);
    margin: 0 auto 24rpx;
    background-color: #fff;
    border-radius: 20rpx;
    min-height: 110rpx;
    display: flex;
    align-items: center;
    padding: 24rpx;

    .label {
      color: #333;
      font-size: 28rpx;
      width: 250rpx;

      &::before {
        content: "*";
        margin: 0 10rpx;
        color: #ea0707;
      }
    }

    .content {
      width: calc(100% - 250rpx);
      font-size: 28rpx;
      text-align: right;
    }

  }

  .card {
    background: white;
    margin-bottom: 16rpx;
    padding: 40rpx 24rpx;
    border-radius: 20rpx;

    &>view:not(:last-child) {
      margin-bottom: 20rpx;
    }
  }
}

.allBtn {
  width: 100%;
  height: 80rpx;
  position: fixed;
  background-color: #fff;
  bottom: 0;
  z-index: 2;
  border-top: 1rpx solid #f5f5f5;

  .btn {
    width: calc(100% - 40rpx);
    margin: 7rpx auto;
    height: 66rpx;
    line-height: 66rpx;
    color: #fff;
    font-size: 28rpx;
    text-align: center;
    border-radius: 40rpx;
    background: $OVERALL_CONFIRM_BUTTON_COLOR;
  }
}
</style>